package com.example.rpcclient.controller;

import com.example.UserProto;
import com.example.UserServiceGrpc;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @GrpcClient("grpc-server")
    private UserServiceGrpc.UserServiceBlockingStub stub;

    @RequestMapping("/test")
    public String test() {
        UserProto.UserResponse hello = stub.login(UserProto.UserRequest.newBuilder().setName("hello").build());
        return hello.getData().getContent();
    }

}
